// TaskIcon.cs
//

namespace ServiceAdmin
{
    using ServiceAdmin.Status;
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    /// <summary>
    /// Summary description for TaskIcon.
    /// </summary>
    public class TaskIcon
    {
        private         NotifyIcon      _taskIcon   = new NotifyIcon();
        public  event   EventHandler    OnMaximize;


        public string Text
        {
            get { return _taskIcon.Text; }
            set { _taskIcon.Text = value; }
        }


		public Icon Icon
		{
			get { return _taskIcon.Icon; }
			set { _taskIcon.Icon = value; }
		}

        /// <summary>
        /// Creates a new instance of TaskIcon
        /// </summary>
        public TaskIcon(Icon defaultIcon, ContextMenu menu)
        {
            _taskIcon.DoubleClick  += new EventHandler(OnDblClick);

            if (defaultIcon != null)
            {
                _taskIcon.Icon          = defaultIcon;
                _taskIcon.Visible       = true;
                _taskIcon.ContextMenu   = menu;
            }
        }

        public void SetStatus(ServiceStatus status)
        {
			_taskIcon.Icon = status.StatusIcon;
        }


        private void OnDblClick(object sender, EventArgs e)
        {
            if (OnMaximize != null)
            {
                OnMaximize(this, e);
            }
        }
    }
}